import json, utils, app
import xlrd
import requests, unittest, parameterized, time

# dict={"aaa":111}
# print("aaa" in dict.keys())

# print(time.time())
# print(int(round(time.time()*1000)))

# print(int(time.time()*1000))
# print("1621233689792")
# print(len("1621233689792"))


# xl = xlrd.open_workbook(r"C:\Users\by\Documents\WeChat Files\wxid_9ndz2hjuslum21\FileStorage\File\2021-05\XLS 工作表.xls")

# def data_bulid():
#     data_list = []
#     data_dict_keys = []
#
#     data = xlrd.open_workbook(
#         r"C:\Users\by\Documents\WeChat Files\wxid_9ndz2hjuslum21\FileStorage\File\2021-05\XLS 工作表.xls")  # 打开xls文件
#     table = data.sheets()[0]  # 打开第一张表
#     for i in table.row_values(0):  # 获取参数名
#         data_dict_keys.append(i)
#
#     for i in range(1, table.nrows):
#         data_dict_values = table.row_values(i)
#         temp_dict = dict(zip(data_dict_keys, data_dict_values))


# def data_build(f=app.TEST_CASE_PATH):
#     data_list = []
#     data_dict_keys = []
#
#     data = xlrd.open_workbook(f)  # 打开xls文件
#     table = data.sheets()[0]  # 打开第一张表
#     for i in table.row_values(0):  # 获取参数名
#         data_dict_keys.append(i)
#
#     for i in range(1, table.nrows):
#         data_dict_values = table.row_values(i)
#         temp_dict = dict(zip(data_dict_keys, data_dict_values))
#         temp_list=[]
#         temp_list.append(temp_dict)
#         data_list.append(tuple(temp_list))
#     return data_list
#
# for i in data_build():
#     print(i)
# print()


from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = {'browserName': 'chrome',
        'loggingPrefs': {
            'browser': 'ALL',
            'driver': 'ALL',
            'performance': 'ALL',
        },
        'goog:chromeOptions': {
            'perfLoggingPrefs': {
                'enableNetwork': True,
            },
            'w3c': False,
        },
        }

driver = webdriver.Chrome(desired_capabilities=caps)
info = driver.get_log('driver')
print(info)

for i in info:
    dic_info = json.loads(i["message"]) # 把json格式转成字典。
    info = dic_info["message"]['params']# request 信息，在字典的 键 ["message"]['params'] 中。
    if 'request' in info:# 如果找到了 request 信息，就终断循环。
        heard = info['request']
        break

    # def headers(self):
    #     response = self.login_api.get_coken({"mobile": "13800000002", "password": "123456"})
    #     app.TOKEN = "Bearer " + response.json().get('data')
